// pages/myPages/myPages.js
var request = require('./request.js')

//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mobile_phone:'',
    userName:'',
    tempFilePaths:'',
    rate:'',
    tid:'4'
  },
  userInfo: function (e) {
    var that = this;
    var data = {
      access_token: wx.getStorageSync('createUser').access_token
    };
    request.userInfo(data, function (d) {
      wx.setStorageSync('createUser', d)
      that.setData({
        tempFilePaths: d.head_portrait,
        userName: d.nickname, 
        mobile_phone: d.mobile_phone,
        rate: d.rate
      })
    });
  },
  mineEventListener(e){
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  setPage: function (e) {
    wx.navigateTo({
      url: './setPage/setPage'
    })
  },
  messagePage: function (e) {
    wx.navigateTo({
      url: './messagePage/messagePage'
    })
  },
  personalCenter: function (e) {
    wx.navigateTo({
      url: './personalCenter/personalCenter'
    })
  },
  contactsPage: function (e) {
    wx.setStorageSync('chooseKey', 1)
    wx.navigateTo({
      url: './contactsPage/contactsPage?changeId=1'
    })
  },
  transactionRecord: function (e) {
    wx.navigateTo({
      url: './transactionRecord/transactionRecord'
    })
  },
  transferRecord: function (e) {
    wx.navigateTo({
      url: './transferRecord/transferRecord'
    })
  },
  helpCenter: function (e) {
    wx.navigateTo({
      url: './helpCenter/helpCenter'
    })
  },
  aboutUs: function (e) {
    wx.navigateTo({
      url: './aboutUs/aboutUs'
    })
  },  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.userInfo();
    wx.setTabBarItem({
      index: 0,
      text: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].JLTabBarPropertyText : wx.T.locales['en'].JLTabBarPropertyText,
      iconPath: "image/tab_zichan_normal.png",
      selectedIconPath: "image/tab_zichan_selected.png"
    })
      wx.setTabBarItem({
      index: 1,
      text: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].JLTabBarMineText : wx.T.locales['en'].JLTabBarMineText,
      iconPath: "image/tab_my_normal.png",
      selectedIconPath: "image/tab_my_selected.png"
    })

    this.setData({
      setLang: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'] : wx.T.locales['en']

    })
    wx.setNavigationBarTitle({
      title: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].myPage : wx.T.locales['en'].myPage
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})